import { proxy } from "valtio"

interface stateType {
    SearchKey: string,
    SearchRecords: string[],
    ChangeSearchKey: (val: string) => void,
    ChangeSearchRecords: (val: string) => void
    clearChangeSearchRecords: () => void,
    MallRecommended:string, //商城推荐
    ChangeMallRecommended: (val: string) => void,//ADD商城推荐
}

export const state: stateType = proxy({
    SearchKey: "", //搜索
    MallRecommended:'推荐',//商城tab推荐
    SearchRecords: ['sss', '那是什么', '如果有一天,我们彼此', '冬天必备', '五金都有什么', '雨天穿什么', '遗忘我', '枫叶红时,总多离别', '知我者意知此'], //搜索记录
    // 搜索关键字
    ChangeSearchKey: (val: string) => {
        console.log(val)
        state.SearchKey = val
        state.ChangeSearchRecords(val)
    },
    // 搜索记录
    ChangeSearchRecords: (val: string) => {
        console.log(val)
        state.SearchRecords.push(val)
    },
    // 清空搜索记录
    clearChangeSearchRecords: () => {
        state.SearchRecords = []
    },
    //添加商城推荐
    ChangeMallRecommended:(val:string)=>{
        state.MallRecommended=val
    },


})
